#ifndef __TASKQUEUE_HH__
#define __TASKQUEUE_HH__

#include <queue>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <memory>



using std::queue;
using std::mutex;
using std::unique_lock;
using std::condition_variable;
using std::function;
using std::shared_ptr;

class TcpConnection;

class TaskQueue
{
public:
    using Task = function<void(const shared_ptr<TcpConnection>&)>;
public:
    TaskQueue(size_t capacity);
    ~TaskQueue();

    Task pop();
    void push(Task& task);
    void Set_exit(bool flag);

    bool Full();
    bool Empty();

private:
    size_t _capacity;
    queue<Task> _queue;
    mutex _mutex;
    condition_variable _not_full;
    condition_variable _not_empty;
    bool _is_exit;
};

#endif